//
//  LoginViewController.m
//  DaleTou
//
//  Created by wenrong on 2018/5/28.
//  Copyright © 2018年 geren. All rights reserved.
//

#import "LoginViewController.h"
#import "NSString+GNUtil.h"
#import "ShareValue.h"
#import "MBProgressHUD+MJ.h"

@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *password;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor mainLightGrayColor];
    [self setNavConfigStartColor:@"#ff8e01" endColor:@"#ff8e01"];
    [self setNavLeftItemWithTitle:nil img:@"返回" frame:CGRectMake(0, 0, 44, 44)];
}
- (void)leftItemClicked
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (IBAction)forgetPwd {
}

- (IBAction)loginEvent {
    if (![NSString isNewPhoneNumber:self.userName.text]) {
        [MBProgressHUD showError:@"请输入正确手机号"];
        return;
    }
    
    if ([self.userName.text isEqualToString:@""] || self.password.text.length < 6) {
        [MBProgressHUD showError:@"密码不能小于6位"];
        return;
    }
    NSLog(@"%@", [NSString stringWithFormat:@"%@",[ShareValue sharedInstance].password]);
    if ([self.userName.text isEqualToString:[ShareValue sharedInstance].phoneNum] && [self.password.text isEqualToString:[ShareValue sharedInstance].password]) {
        [MBProgressHUD showSuccess:@"登录成功"];
        [ShareValue sharedInstance].isLogin = YES;
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        [MBProgressHUD showError:@"账号或密码错误"];
    }
}
- (IBAction)registerEvent {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
